﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using AuctionModel;
using AuctionLogicController;

namespace AuctionServer
{
    [ServiceBehavior(
        ConcurrencyMode = ConcurrencyMode.Reentrant,
        InstanceContextMode = InstanceContextMode.PerSession)]
    public class AuctionService : IAuctionService
    {
        public void CreateUser(User user)
        {
            UserController.CreateUser(user);
        }

        public User Login(string userName, string password)
        {
            return UserController.Login(userName, password);
        }

        public void CreateAuction(Auction auction, List<Item> items)
        {
            auction.Items = items;
            var theAuction = auction;
            AuctionController.CreateAuction(theAuction);

            foreach (var item in items)
            {
                AuctionController.AddItemToAuction(auction, item);
            }
        }
        public Auction ShowAuction(int id)
        {
            return AuctionController.GetAuction(id);
        }
        public void PlaceBid(Bid bid)
        {
            AuctionController.BidOnItem(bid);
        }
        public int GetTopBid(Item item)
        {
            return AuctionController.GetTopBid(item);
        }
        public void StartAuction(DateTime startTime)
        {
            throw new NotImplementedException();
        }

        public void EndAuction(DateTime endTime)
        {
            throw new NotImplementedException();
        }
        public List<Auction>GetAllAuctions()
        {
            return AuctionController.GetAllAuctions();
        }
        public List<Item>GetAllItems()
        {
            return AuctionController.GetAllItems();
        }
        public void AddItemToAuction(Auction auction, Item item)
        {
            //AuctionController.AddItemToAuction();
        }
    }
}
